﻿@model IEnumerable<TravelWeb.Models.Order>
@{
    ViewBag.Title = "Order";
}
<h2>
    Order</h2>
<table>
    <tr>
        <th>
            Customer
        </th>
        <th>
            Tour
        </th>
        <th>
            Schedule
        </th>
        <th>
            Payment Type
        </th>
        <th>
            Adult
        </th>
        <th>
            Child
        </th>
        <th>
            Total Price
        </th>
        <th>
            Promotion
        </th>
        <th>
            Order Date
        </th>
        <th>
            Status
        </th>
        <th>
        </th>
    </tr>
    @if (User.IsInRole("User"))
    {
        foreach (var item in Model)
        {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Customer.Username)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Tour.TourName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Schedule.ScheduleName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.PaymentType)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.numOfAdult)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.numOfChild)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.TotalPrice)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Promotion.PromotionName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.OrderDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Status)
            </td>
            <td>
                @if (item.Status.Equals("New"))
                {
                    @Html.ActionLink("Confirm", "Confirm", new { id = item.OrderID });
                }
                @if (item.Schedule.ConfirmDate >= DateTime.Now)
                {
                    @Html.ActionLink("Cancel", "Delete", new { id = item.OrderID });
                }
                @Html.ActionLink("Details", "Details", new { id = item.OrderID });
            </td>
        </tr>
        }
    }
    @if (User.IsInRole("Manager"))
    {
        foreach (var item in Model)
        {
            if (!item.Status.Equals("Canceled"))
            {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Customer.Username)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Tour.TourName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Schedule.ScheduleName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.PaymentType)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.numOfAdult)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.numOfChild)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.TotalPrice)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Promotion.PromotionName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.OrderDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Status)
            </td>
            <td>
                @Html.ActionLink("Approve", "Approve", new { id = item.OrderID });
                @Html.ActionLink("Details", "Details", new { id = item.OrderID });
                @if (item.Schedule.StartDate >= DateTime.Now)
                {
                    @Html.ActionLink("Cancel", "Delete", new { id = item.OrderID });
                }
            </td>
        </tr>
            }
        }
    }
</table>
